package com.qf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.pojo.DtsGoods;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品基本信息表 Mapper 接口
 * </p>
 *
 * @author zhaojian
 * @since 2021-05-12
 */
public interface DtsGoodsMapper extends BaseMapper<DtsGoods> {
@Select("  SELECT  " +
        "o.`goods_price` AS amount , " +
        "COUNT(o.id) AS orders, " +
        "DATE_FORMAT(o.`add_time`,\"%Y-%m-%d\") AS day, " +
        "SUM(og.`number`) AS products " +
        "FROM `dts_order` o " +
        "LEFT JOIN `dts_order_goods` og ON og.`order_id`=o.`id` " +
        "LEFT JOIN `dts_goods` g ON g.`id`=og.`goods_id` " +
        "LEFT JOIN `dts_goods_product` gp ON gp.`goods_id`= g.`id` " +
        "WHERE o.`deleted` = 0 " +
        "GROUP BY  day ")
    List<Map> selectOrder();
}
